<%-- 
    Document   : index
    Created on : Jul 7, 2011, 1:23:40 AM
    Author     : Thanhluan216
--%>

<%@page import="server.entity.RegisteredUser"%>
<%@page import="server.entity.Photo"%>
<%@page import="server.process.ProcessBeanLocal"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="javax.naming.Context"%>
<%@page import="javax.naming.InitialContext"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<jsp:include page="header.jsp"></jsp:include>
<div id="main">
    <div id="slidebar">
        <div id="login">
            <jsp:include page="login.jsp"></jsp:include>
        </div>
        <div id="search">
            <jsp:include page="search.jsp"></jsp:include>
        </div>
        <div id="product">
            <jsp:include page="categorypanel.jsp"></jsp:include>
        </div>
    </div>
    <div id="content">
        <%
                    Context ctx = new InitialContext();
                    ProcessBeanLocal local = (ProcessBeanLocal) ctx.lookup("ProcessLocalJNDI");
                    int photoID=0;
                    photoID = Integer.parseInt(request.getParameter("id"));
                    local.viewPhoto(photoID);
                    Photo photo = local.searchbyID(photoID);
                    DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
                    
        %>
        Photo <a href='view.jsp?id=<%=request.getParameter("id")%>'><%=photo.getPhotoName()%></a> | Upload by <a href="viewuser.jsp?id=<%=photo.getRegisteredUser().getUsername()%>"><%=photo.getRegisteredUser().getUsername()%></a> | Category: <a href="category.jsp?id=<%=photo.getCategory().getCollectionID()%>"><%=photo.getCategory().getCollectionName()%></a>
        <center>

            <form name="action" method="POST">
                <table border="0">
                    <tr>
                        <td colspan="3"><img src="<%=photo.getServerFile()%>" height="300" width="400"/><br/>Upload by <a href="#"></a> | Date upload: <%=df.format(photo.getUploaddate())%> | View: <%=photo.getViews()%> | Download <%=photo.getDownloads()%></td>
                    </tr>
                    <tr>
                        <td><a href="comment.jsp?id=<%=request.getParameter("id")%>&action=comment">Comment</a></td>

                        <td><a href="viewallcomment.jsp?id=<%=request.getParameter("id")%>&action=viewall">View All () comment</a></td>
                        <td><a href="download?id=<%=request.getParameter("id")%>&action=download">Download this photo</a></td>
                    </tr>
                    <%

                                RegisteredUser registeredUser = null;
                                if (session.getAttribute("username") != null) {
                                    registeredUser = local.findUserbyID(session.getAttribute("username").toString());
                                }
                    %>
                </table>
                
            </form>
        </center>
    </div>
</div>
<div id="footer">

</div>
</div>
</body>
</html>
